<?php
/* $Id: funcs.php,v 1.3 2003/10/08 07:11:12 tuxmonkey Exp $ */
/** 
 * @package Issue-Tracker
 * @subpackage Administration
 */

if (strpos($_SERVER['PHP_SELF'],basename(__FILE__)) !== false) 
{print "Direct module access forbidden.";exit;}

/* {{{ Function: colorize_log */
/**
 * Colorize log output for easy viewing
 *
 * @param string $buffer Information to colorize
 */
function colorize_log($buffer)
{
  $buffer = str_replace("[","<font color=\"red\">[</font>",$buffer);
  $buffer = str_replace("]","<font color=\"red\">]</font>",$buffer);
  $buffer = str_replace("(","<font color=\"red\">(</font>",$buffer);
  $buffer = str_replace(")","<font color=\"red\">)</font>",$buffer);
  $buffer = str_replace("{","<font color=\"red\">{</font>",$buffer);
  $buffer = str_replace("}","<font color=\"red\">}</font>",$buffer);
  $buffer = str_replace("Array","<font color=\"blue\">Array</font>",$buffer);
  $buffer = str_replace("=>","<font color=\"magenta\">=></font>",$buffer);
  $buffer = str_replace(":","<font color=\"green\">:</font>",$buffer);
  return $buffer;
}
function add_stat($father,$son)
{
  global $dbi;
	
  // check to make sure this user isn't already in the group
  $sql  = "SELECT sid_out FROM statuses_workflow ";
  $sql .= "WHERE sid_in='$father' ";
  $sql .= "AND sid_out='$son'";
  $result = $dbi->query($sql);
  if($dbi->num_rows($result) > 0){
    $dbi->free($result);
    return;
  }

  // form insert array
  $insert["sid_in"]  = $father;
  $insert["sid_out"] = $son;
  $dbi->insert("statuses_workflow",$insert);
}

function del_stat($father,$son)
{
  // pull globals
    global $dbi; 

	$sql  = "DELETE FROM statuses_workflow WHERE sid_in='$father' AND sid_out='$son'";
	$result = $dbi->query($sql);
	  
    if ($dbi->affected_rows($result) == 1)    
        return TRUE;
    else
        return FALSE;
}
function add_task($father,$son)
{
  global $dbi;
	
  // check to make sure this user isn't already in the group
  $sql  = "SELECT ttask FROM categorie_tasks ";
  $sql .= "WHERE cid='$father' ";
  $sql .= "AND ttask='$son'";
  $result = $dbi->query($sql);
  if($dbi->num_rows($result) > 0){
    $dbi->free($result);
    return;
  }

  // form insert array
  $insert["cid"]  = $father;
  $insert["ttask"] = $son;
  $dbi->insert("categorie_tasks",$insert);
}

function del_task($father,$son)
{
  // pull globals
    global $dbi; 

	$sql  = "DELETE FROM categorie_tasks WHERE cid='$father' AND ttask='$son'";
	$result = $dbi->query($sql);
	  
    if ($dbi->affected_rows($result) == 1)    
        return TRUE;
    else
        return FALSE;
}

/* }}} */
?>
